﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CLVisionTcpIP;

namespace Demo
{
    public partial class TcpClientDemo: Form
    {
        public TcpClientDemo()
        {
            InitializeComponent();
        }
        CLTcpClient tcpClient = new CLTcpClient();
        private void button1_Click(object sender, EventArgs e)
        {
           

            tcpClient.OnMessageReceived = (msg) =>
            {
                this.Invoke(new Action(() =>
                {
                    listBox1.Items.Add(msg);
                    }));
            };
            string IP = textBox2.Text;
            int port = int.Parse(textBox3.Text);
            tcpClient.Connect(IP, port);


        }

        private void button2_Click(object sender, EventArgs e)
        {
            string Sendtext = textBox1.Text;
            tcpClient.Send(Sendtext);
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
